package com.learn.order.listener;

import com.learn.order.domain.Order;
import com.learn.order.mapper.OrderMapper;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;

@Component
public class TimeoutOrderListener {

    @Resource
    OrderMapper orderMapper;

    @RabbitListener(queues = "q.order.dlx")
    public void onMessage(String orderId)  {

        Order orderInfo = orderMapper.selectById(Integer.valueOf(orderId));

        //未支付
        if(orderInfo.getStatus().equals(0)) {
            orderInfo.setStatus(2);
            orderMapper.updateById(orderInfo);
        }

    }
}
